home *** CD-ROM | disk | FTP | other *** search
- /* stime.c Turbo C Bible Functions, p. 336 */
- #include <stdio.h>
- #include <dos.h>
- #include <time.h>
- main()
- {
- int d, m, y, h, min, sec;
- long uxtime;
- struct date date;
- struct time time;
- getdate(&date);
- /* Get current data and time and prompt for new values */
- printf("The date is %d-%d-%d\nEnter new date:",
- date.da_mon, date.da_day, date.da_year);
- scanf(" %d-%d-%d", &m, &d, &y);
- gettime(&time);
- printf("Current time is %02d:%02d:%02d\nEnter new time:",
- time.ti_hour, time.ti_min, time.ti_sec);
- scanf(" %d: %d: %d", &h, &min, &sec);
- date.da_year = y;
- /* Copy date and time into the date and time structures */
- date.da_mon = m;
- date.da_day = d;
- time.ti_hour = h;
- time.ti_min = min;
- time.ti_sec = sec;
- uxtime = dostounix(&date, &time);
- /* Convert date and time to UNIX format */
- stime(&uxtime); /* Set date and time using stime */
- printf("Date and time set. Verify using DOS"
- " commands DATE and TIME\n");
- }